<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let singleTon = (function () {
        function Fun() {
          this.prop = "";
        }
        Fun.prototype.fn = function () {};

        return {
          getInstance() {
            //在方法里生成实例
            return new Fun();
          },
        };
      })();
      console.log(singleTon.getInstance());
      console.log(singleTon.getInstance() == singleTon.getInstance());
  </script>
</body>
</html>